package com.david.avcodec.system

import android.app.Activity
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.provider.MediaStore
import android.util.Log
import android.view.View
import com.david.avcodec.R

//参考链接：https://developer.android.google.cn/training/camera/videobasics?hl=zh-cn
class SystemVideoActivity: Activity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_system_video)
        findViewById<View>(R.id.test_btn).setOnClickListener {
            val intent = Intent(MediaStore.ACTION_VIDEO_CAPTURE)
            intent.resolveActivity(packageManager)
            startActivityForResult(intent, 1)
        }
    }

    override fun onActivityResult(requestCode: Int, resultCode: Int, intent: Intent) {
        if (requestCode == 1 && resultCode == RESULT_OK) {
            val videoUri: Uri? = intent.data
            Log.e("url", videoUri.toString())//录制之后的操作
        }
    }
}